import mitt from 'mitt'

/**
 * 自定义事件:刷新当前路由组件
 */
export const refreshCur = Symbol('refreshCur')
/**
 * 自定义事件:关闭当前标签,并转入新路由
 */
export const closeCurAndToRoute = Symbol('closeCur')

const emitter = mitt()

export const RouterViewKeepAliveWrapperEvent = {
  /**
   * 自定义事件:刷新当前路由组件
   */
  [refreshCur]: () => {
    emitter.emit(refreshCur)
  },
}

export const RouteTabsEvent = {
  /**
   * 自定义事件:关闭当前标签,并转入新路由
   */
  [closeCurAndToRoute]: toRoute => {
    emitter.emit(closeCurAndToRoute, toRoute)
  },
}
